import java.util.ArrayList;

public class Main {
    static ArrayList<ArrayList> students = new ArrayList<ArrayList>();
    static int[] scores = {0,0,0,0,0,0};

    public static void main(String[] args){
        ReadWrite.read("src/stuList.txt", students, scores);
        ReadWrite.read("src/scoreList.txt", students, scores);
        sort();
        ReadWrite.write("src/endList.txt", students, scores);
    }

    //计数排序
    static void sort(){
        int[] mediums = new int[501];
        int medium = students.size();
        ArrayList<ArrayList> students1 = new ArrayList<ArrayList>(medium);

        for(int i = 250; i < 501; i++)
            mediums[i] = 0;
        for(int i = 0; i < medium; i++) {
            mediums[(int) students.get(i).get(0)]++;
            students1.add(null);
        }
        for(int i = 251; i < 501; i++)
            mediums[i] += mediums[i-1];
        for(int i = 0; i < medium; i++) {
            students1.set(mediums[(int)students.get(i).get(0)]-1, students.get(i));
            mediums[(int)students.get(i).get(0)]--;
        }
        students = students1;
    }

}

